﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Text;

namespace WMI.NET.CIM
{
    /// <summary>
    /// The CIM_ControlledBy relationship indicates which devices are commanded by, or accessed through, the controller logical device. 
    /// </summary>
    public class CIM_ControlledBy : CIM_DeviceConnection
    {

        private Nullable<UInt16> _AccessState;
        private Nullable<UInt32> _NumberOfHardResets;
        private Nullable<UInt32> _NumberOfSoftResets;

        /// <summary>
        /// Indicates whether the controller is actively commanding or accessing the device. This information is necessary when a logical device can be commanded by, or accessed through, multiple controllers.
        /// </summary>
        public Nullable<UInt16> AccessState { get { return _AccessState; } } //TODO enum

        /// <summary>
        /// Number of hard resets issued by the controller. A hard reset returns the device to its initialization or boot-up state. All internal device state information and data are lost.
        /// </summary>
        public Nullable<UInt32> NumberOfHardResets { get { return _NumberOfHardResets; } }

        /// <summary>
        /// Number of soft resets issued by the controller. A soft reset does not completely clear current device state and data. Exact semantics are dependent on the device and on the protocols and mechanisms used to communicate to it.
        /// </summary>
        public Nullable<UInt32> NumberOfSoftResets { get { return _NumberOfSoftResets; } }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="mbo"></param>
        public CIM_ControlledBy(ManagementBaseObject mbo)
            : base(mbo)
        {
            _AccessState = mbo.GetUshortValue("AccessState");
            _NumberOfHardResets = mbo.GetUIntValue("NumberOfHardResets");
            _NumberOfSoftResets = mbo.GetUIntValue("NumberOfSoftResets");
        }

    }

}
